package com.ruoyi.project.access.service;


import com.ruoyi.project.access.domain.*;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Component
public class DataAttributeExtractionService {
    @Autowired
    private EnterpriseBasicInfoService enterpriseBasicInfoService;

    public void extractDataInfos(Map<String, Object> enterpriseInfos) {
        extractEnterpriseBasicInfo(enterpriseInfos);
        extractHumanResourceInfos(enterpriseInfos);
        extractBusinessStatusInfos(enterpriseInfos);
        extractMaterialManagementInfos(enterpriseInfos);
        extractProductionCapacityInfos(enterpriseInfos);
        extractSaleCapabilityInfos(enterpriseInfos);
    }

    public EnterpriseBasicInfo extractEnterpriseBasicInfo(Map<String, Object> enterpriseInfos) {
//        List<EnterpriseBasicInfo> enterpriseBasicInfos = new ArrayList<>();
//        try {
//            EnterpriseBasicInfo info = new EnterpriseBasicInfo();
//            if (enterpriseInfos.containsKey(DataFields.chainType)) {
//                info.setChainType(String.valueOf(enterpriseInfos.get(DataFields.chainType)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.enterpriseName)) {
//                info.setEnterpriseName(String.valueOf(enterpriseInfos.get(DataFields.enterpriseName)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.scenario)) {
//                info.setScenario(String.valueOf(enterpriseInfos.get(DataFields.scenario)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.product)) {
//                info.setProduct(String.valueOf(enterpriseInfos.get(DataFields.product)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.enterpriseType)) {
//                info.setEnterpriseType(String.valueOf(enterpriseInfos.get(DataFields.enterpriseType)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.enterpriseAddress)) {
//                info.setEnterpriseAddress(String.valueOf(enterpriseInfos.get(DataFields.enterpriseAddress)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.industryCategory)) {
//                info.setIndustryCategory(String.valueOf(enterpriseInfos.get(DataFields.industryCategory)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.enterpriseScale)) {
//                info.setEnterpriseScale(String.valueOf(enterpriseInfos.get(DataFields.enterpriseScale)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.establishmentDate)) {
//                info.setEstablishmentDate(String.valueOf(enterpriseInfos.get(DataFields.establishmentDate)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.registeredCapital)) {
//                info.setRegisteredCapital(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.registeredCapital))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.legalRepresentative)) {
//                info.setLegalRepresentative(String.valueOf(enterpriseInfos.get(DataFields.legalRepresentative)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.eventTime)) {
//                info.setEventTime(Long.parseLong(String.valueOf(enterpriseInfos.get(DataFields.eventTime))));
//            }
//            enterpriseBasicInfos.add(info);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
        //enterpriseBasicInfoService.addEnterpriseBasicInfos(enterpriseBasicInfos);
        //return enterpriseBasicInfos;

        EnterpriseBasicInfo info = new EnterpriseBasicInfo();
        if (enterpriseInfos.containsKey(DataFields.chainType)) {
            info.setChainType(String.valueOf(enterpriseInfos.get(DataFields.chainType)));
        }
        if (enterpriseInfos.containsKey(DataFields.enterpriseName)) {
            info.setEnterpriseName(String.valueOf(enterpriseInfos.get(DataFields.enterpriseName)));
        }
        if (enterpriseInfos.containsKey(DataFields.scenario)) {
            info.setScenario(String.valueOf(enterpriseInfos.get(DataFields.scenario)));
        }
        if (enterpriseInfos.containsKey(DataFields.product)) {
            info.setProduct(String.valueOf(enterpriseInfos.get(DataFields.product)));
        }
        if (enterpriseInfos.containsKey(DataFields.enterpriseType)) {
            info.setEnterpriseType(String.valueOf(enterpriseInfos.get(DataFields.enterpriseType)));
        }
        if (enterpriseInfos.containsKey(DataFields.enterpriseAddress)) {
            info.setEnterpriseAddress(String.valueOf(enterpriseInfos.get(DataFields.enterpriseAddress)));
        }
        if (enterpriseInfos.containsKey(DataFields.industryCategory)) {
            info.setIndustryCategory(String.valueOf(enterpriseInfos.get(DataFields.industryCategory)));
        }
        if (enterpriseInfos.containsKey(DataFields.enterpriseScale)) {
            info.setEnterpriseScale(String.valueOf(enterpriseInfos.get(DataFields.enterpriseScale)));
        }
        if (enterpriseInfos.containsKey(DataFields.establishmentDate)) {
            info.setEstablishmentDate(String.valueOf(enterpriseInfos.get(DataFields.establishmentDate)));
        }
        if (enterpriseInfos.containsKey(DataFields.registeredCapital)) {
            info.setRegisteredCapital(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.registeredCapital))));
        }
        if (enterpriseInfos.containsKey(DataFields.legalRepresentative)) {
            info.setLegalRepresentative(String.valueOf(enterpriseInfos.get(DataFields.legalRepresentative)));
        }
        if (enterpriseInfos.containsKey(DataFields.eventTime)) {
            info.setEventTime(Long.parseLong(String.valueOf(enterpriseInfos.get(DataFields.eventTime))));
        }
        return info;
    }

    public HumanResourceInfo extractHumanResourceInfos(Map<String, Object> enterpriseInfos) {
//        List<HumanResourceInfo> humanResourceInfos = new ArrayList<>();
//        try {
//            HumanResourceInfo info = new HumanResourceInfo();
//            if (enterpriseInfos.containsKey(DataFields.chainType)) {
//                info.setChainType(String.valueOf(enterpriseInfos.get(DataFields.chainType)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.enterpriseName)) {
//                info.setEnterpriseName(String.valueOf(enterpriseInfos.get(DataFields.enterpriseName)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.scenario)) {
//                info.setScenario(String.valueOf(enterpriseInfos.get(DataFields.scenario)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.product)) {
//                info.setProduct(String.valueOf(enterpriseInfos.get(DataFields.product)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.amount)) {
//                info.setAmount(Long.parseLong(String.valueOf(enterpriseInfos.get(DataFields.amount))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.trainingEffect)) {
//                info.setTrainingEffect(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.trainingEffect))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.employeeSkillLevel)) {
//                info.setEmployeeSkillLevel(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.employeeSkillLevel))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.eventTime)) {
//                info.setEventTime(Long.parseLong(String.valueOf(enterpriseInfos.get(DataFields.eventTime))));
//            }
//            humanResourceInfos.add(info);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }

        //enterpriseBasicInfoService.addHumanResourceInfos(humanResourceInfos);
        //return humanResourceInfos;

        HumanResourceInfo info = new HumanResourceInfo();
        if (enterpriseInfos.containsKey(DataFields.chainType)) {
            info.setChainType(String.valueOf(enterpriseInfos.get(DataFields.chainType)));
        }
        if (enterpriseInfos.containsKey(DataFields.enterpriseName)) {
            info.setEnterpriseName(String.valueOf(enterpriseInfos.get(DataFields.enterpriseName)));
        }
        if (enterpriseInfos.containsKey(DataFields.scenario)) {
            info.setScenario(String.valueOf(enterpriseInfos.get(DataFields.scenario)));
        }
        if (enterpriseInfos.containsKey(DataFields.product)) {
            info.setProduct(String.valueOf(enterpriseInfos.get(DataFields.product)));
        }
        if (enterpriseInfos.containsKey(DataFields.amount)) {
            info.setAmount(Long.parseLong(String.valueOf(enterpriseInfos.get(DataFields.amount))));
        }
        if (enterpriseInfos.containsKey(DataFields.trainingEffect)) {
            info.setTrainingEffect(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.trainingEffect))));
        }
        if (enterpriseInfos.containsKey(DataFields.employeeSkillLevel)) {
            info.setEmployeeSkillLevel(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.employeeSkillLevel))));
        }
        if (enterpriseInfos.containsKey(DataFields.eventTime)) {
            info.setEventTime(Long.parseLong(String.valueOf(enterpriseInfos.get(DataFields.eventTime))));
        }
        return info;
    }

    public BusinessStatusInfo extractBusinessStatusInfos(Map<String, Object> enterpriseInfos) {
//        List<BusinessStatusInfo> businessStatusInfos = new ArrayList<>();
//        try {
//            BusinessStatusInfo info = new BusinessStatusInfo();
//            if (enterpriseInfos.containsKey(DataFields.chainType)) {
//                info.setChainType(String.valueOf(enterpriseInfos.get(DataFields.chainType)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.enterpriseName)) {
//                info.setEnterpriseName(String.valueOf( enterpriseInfos.get(DataFields.enterpriseName)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.scenario)) {
//                info.setScenario(String.valueOf(enterpriseInfos.get(DataFields.scenario)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.product)) {
//                info.setProduct(String.valueOf(enterpriseInfos.get(DataFields.product)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.annualRevenue)) {
//                info.setAnnualRevenue(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.annualRevenue))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.annualProfit)) {
//                info.setAnnualProfit(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.annualProfit))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.annualCost)) {
//                info.setAnnualCost(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.annualCost))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.averagePaymentPeriod)) {
//                info.setAveragePaymentPeriod(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.averagePaymentPeriod))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.debtRatio)) {
//                info.setDebtRatio(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.debtRatio))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.eventTime)) {
//                info.setEventTime(Long.parseLong(String.valueOf(enterpriseInfos.get(DataFields.eventTime))));
//            }
//            businessStatusInfos.add(info);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return businessStatusInfos;

        BusinessStatusInfo info = new BusinessStatusInfo();
        if (enterpriseInfos.containsKey(DataFields.chainType)) {
            info.setChainType(String.valueOf(enterpriseInfos.get(DataFields.chainType)));
        }
        if (enterpriseInfos.containsKey(DataFields.enterpriseName)) {
            info.setEnterpriseName(String.valueOf( enterpriseInfos.get(DataFields.enterpriseName)));
        }
        if (enterpriseInfos.containsKey(DataFields.scenario)) {
            info.setScenario(String.valueOf(enterpriseInfos.get(DataFields.scenario)));
        }
        if (enterpriseInfos.containsKey(DataFields.product)) {
            info.setProduct(String.valueOf(enterpriseInfos.get(DataFields.product)));
        }
        if (enterpriseInfos.containsKey(DataFields.annualRevenue)) {
            info.setAnnualRevenue(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.annualRevenue))));
        }
        if (enterpriseInfos.containsKey(DataFields.annualProfit)) {
            info.setAnnualProfit(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.annualProfit))));
        }
        if (enterpriseInfos.containsKey(DataFields.annualCost)) {
            info.setAnnualCost(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.annualCost))));
        }
        if (enterpriseInfos.containsKey(DataFields.averagePaymentPeriod)) {
            info.setAveragePaymentPeriod(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.averagePaymentPeriod))));
        }
        if (enterpriseInfos.containsKey(DataFields.debtRatio)) {
            info.setDebtRatio(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.debtRatio))));
        }
        if (enterpriseInfos.containsKey(DataFields.eventTime)) {
            info.setEventTime(Long.parseLong(String.valueOf(enterpriseInfos.get(DataFields.eventTime))));
        }
        return info;
    }

    public MaterialManagementInfo extractMaterialManagementInfos(Map<String, Object> enterpriseInfos) {
//        List<MaterialManagementInfo> materialManagementInfos = new ArrayList<>();
//        try {
//            MaterialManagementInfo info = new MaterialManagementInfo();
//            if (enterpriseInfos.containsKey(DataFields.chainType)) {
//                info.setChainType(String.valueOf(enterpriseInfos.get(DataFields.chainType)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.enterpriseName)) {
//                info.setEnterpriseName(String.valueOf(enterpriseInfos.get(DataFields.enterpriseName)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.scenario)) {
//                info.setScenario(String.valueOf(enterpriseInfos.get(DataFields.scenario)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.product)) {
//                info.setProduct(String.valueOf(enterpriseInfos.get(DataFields.product)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.inventoryVolume)) {
//                info.setInventoryVolume(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.inventoryVolume))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.warehouseQuantity)) {
//                info.setWarehouseQuantity(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.warehouseQuantity))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.warehouseAutomationLevel)) {
//                info.setWarehouseAutomationLevel((Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.warehouseAutomationLevel)))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.transportationMethod)) {
//                info.setTransportationMethod(String.valueOf(enterpriseInfos.get(DataFields.transportationMethod)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.averageDeliveryCycle)) {
//                info.setAverageDeliveryCycle(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.averageDeliveryCycle))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.transportationCapacity)) {
//                info.setTransportationCapacity(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.transportationCapacity))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.onTimeDeliveryRate)) {
//                info.setOnTimeDeliveryRate(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.onTimeDeliveryRate))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.transportationCost)) {
//                info.setTransportationCost(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.transportationCost))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.transportationDamageRate)) {
//                info.setTransportationDamageRate(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.transportationDamageRate))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.eventTime)) {
//                info.setEventTime(Long.parseLong(String.valueOf(enterpriseInfos.get(DataFields.eventTime))));
//            }
//            materialManagementInfos.add(info);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }

        //enterpriseBasicInfoService.addMaterialManagementInfos(materialManagementInfos);
        //return materialManagementInfos;

        MaterialManagementInfo info = new MaterialManagementInfo();
        if (enterpriseInfos.containsKey(DataFields.chainType)) {
            info.setChainType(String.valueOf(enterpriseInfos.get(DataFields.chainType)));
        }
        if (enterpriseInfos.containsKey(DataFields.enterpriseName)) {
            info.setEnterpriseName(String.valueOf(enterpriseInfos.get(DataFields.enterpriseName)));
        }
        if (enterpriseInfos.containsKey(DataFields.scenario)) {
            info.setScenario(String.valueOf(enterpriseInfos.get(DataFields.scenario)));
        }
        if (enterpriseInfos.containsKey(DataFields.product)) {
            info.setProduct(String.valueOf(enterpriseInfos.get(DataFields.product)));
        }
        if (enterpriseInfos.containsKey(DataFields.inventoryVolume)) {
            info.setInventoryVolume(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.inventoryVolume))));
        }
        if (enterpriseInfos.containsKey(DataFields.warehouseQuantity)) {
            info.setWarehouseQuantity(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.warehouseQuantity))));
        }
        if (enterpriseInfos.containsKey(DataFields.warehouseAutomationLevel)) {
            info.setWarehouseAutomationLevel((Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.warehouseAutomationLevel)))));
        }
        if (enterpriseInfos.containsKey(DataFields.transportationMethod)) {
            info.setTransportationMethod(String.valueOf(enterpriseInfos.get(DataFields.transportationMethod)));
        }
        if (enterpriseInfos.containsKey(DataFields.averageDeliveryCycle)) {
            info.setAverageDeliveryCycle(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.averageDeliveryCycle))));
        }
        if (enterpriseInfos.containsKey(DataFields.transportationCapacity)) {
            info.setTransportationCapacity(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.transportationCapacity))));
        }
        if (enterpriseInfos.containsKey(DataFields.onTimeDeliveryRate)) {
            info.setOnTimeDeliveryRate(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.onTimeDeliveryRate))));
        }
        if (enterpriseInfos.containsKey(DataFields.transportationCost)) {
            info.setTransportationCost(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.transportationCost))));
        }
        if (enterpriseInfos.containsKey(DataFields.transportationDamageRate)) {
            info.setTransportationDamageRate(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.transportationDamageRate))));
        }
        if (enterpriseInfos.containsKey(DataFields.eventTime)) {
            info.setEventTime(Long.parseLong(String.valueOf(enterpriseInfos.get(DataFields.eventTime))));
        }
        return info;
    }

    public ProductionCapacityInfo extractProductionCapacityInfos(Map<String, Object> enterpriseInfos) {
//        List<ProductionCapacityInfo> productionCapacityInfos = new ArrayList<>();
//        try {
//            ProductionCapacityInfo info = new ProductionCapacityInfo();
//            if (enterpriseInfos.containsKey(DataFields.chainType)) {
//                info.setChainType(String.valueOf(enterpriseInfos.get(DataFields.chainType)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.enterpriseName)) {
//                info.setEnterpriseName(String.valueOf(enterpriseInfos.get(DataFields.enterpriseName)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.scenario)) {
//                info.setScenario(String.valueOf(enterpriseInfos.get(DataFields.scenario)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.product)) {
//                info.setProduct(String.valueOf(enterpriseInfos.get(DataFields.product)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.productionLineCount)) {
//                info.setProductionLineCount(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.productionLineCount))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.equipmentCount)) {
//                info.setEquipmentCount(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.equipmentCount))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.equipmentAutomationLevel)) {
//                info.setEquipmentAutomationLevel(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.equipmentAutomationLevel))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.monthlyCapacity)) {
//                info.setMonthlyCapacity(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.monthlyCapacity))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.monthlyUtilizationRate)) {
//                info.setMonthlyUtilizationRate(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.monthlyUtilizationRate))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.maxCapacity)) {
//                info.setMaxCapacity(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.maxCapacity))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.averageProductionCycle)) {
//                info.setAverageProductionCycle(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.averageProductionCycle))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.equipmentFailureRate)) {
//                info.setEquipmentFailureRate(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.equipmentFailureRate))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.qualityCheckPassRate)) {
//                info.setQualityCheckPassRate(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.qualityCheckPassRate))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.qualityCertificateCount)) {
//                info.setQualityCertificateCount(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.qualityCertificateCount))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.newProductDevelopmentCycle)) {
//                info.setNewProductDevelopmentCycle(Integer.valueOf(String.valueOf(enterpriseInfos.get(DataFields.newProductDevelopmentCycle))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.patentCount)) {
//                info.setPatentCount(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.patentCount))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.averageOrderResponseSpeed)) {
//                info.setAverageOrderResponseSpeed(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.averageOrderResponseSpeed))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.eventTime)) {
//                info.setEventTime(Long.parseLong(String.valueOf(enterpriseInfos.get(DataFields.eventTime))));
//            }
//
//            productionCapacityInfos.add(info);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }

        //enterpriseBasicInfoService.addProductionCapacityInfos(productionCapacityInfos);
        //return productionCapacityInfos;

        ProductionCapacityInfo info = new ProductionCapacityInfo();
        if (enterpriseInfos.containsKey(DataFields.chainType)) {
            info.setChainType(String.valueOf(enterpriseInfos.get(DataFields.chainType)));
        }
        if (enterpriseInfos.containsKey(DataFields.enterpriseName)) {
            info.setEnterpriseName(String.valueOf(enterpriseInfos.get(DataFields.enterpriseName)));
        }
        if (enterpriseInfos.containsKey(DataFields.scenario)) {
            info.setScenario(String.valueOf(enterpriseInfos.get(DataFields.scenario)));
        }
        if (enterpriseInfos.containsKey(DataFields.product)) {
            info.setProduct(String.valueOf(enterpriseInfos.get(DataFields.product)));
        }
        if (enterpriseInfos.containsKey(DataFields.productionLineCount)) {
            info.setProductionLineCount(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.productionLineCount))));
        }
        if (enterpriseInfos.containsKey(DataFields.equipmentCount)) {
            info.setEquipmentCount(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.equipmentCount))));
        }
        if (enterpriseInfos.containsKey(DataFields.equipmentAutomationLevel)) {
            info.setEquipmentAutomationLevel(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.equipmentAutomationLevel))));
        }
        if (enterpriseInfos.containsKey(DataFields.monthlyCapacity)) {
            info.setMonthlyCapacity(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.monthlyCapacity))));
        }
        if (enterpriseInfos.containsKey(DataFields.monthlyUtilizationRate)) {
            info.setMonthlyUtilizationRate(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.monthlyUtilizationRate))));
        }
        if (enterpriseInfos.containsKey(DataFields.maxCapacity)) {
            info.setMaxCapacity(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.maxCapacity))));
        }
        if (enterpriseInfos.containsKey(DataFields.averageProductionCycle)) {
            info.setAverageProductionCycle(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.averageProductionCycle))));
        }
        if (enterpriseInfos.containsKey(DataFields.equipmentFailureRate)) {
            info.setEquipmentFailureRate(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.equipmentFailureRate))));
        }
        if (enterpriseInfos.containsKey(DataFields.qualityCheckPassRate)) {
            info.setQualityCheckPassRate(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.qualityCheckPassRate))));
        }
        if (enterpriseInfos.containsKey(DataFields.qualityCertificateCount)) {
            info.setQualityCertificateCount(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.qualityCertificateCount))));
        }
        if (enterpriseInfos.containsKey(DataFields.newProductDevelopmentCycle)) {
            info.setNewProductDevelopmentCycle(Integer.valueOf(String.valueOf(enterpriseInfos.get(DataFields.newProductDevelopmentCycle))));
        }
        if (enterpriseInfos.containsKey(DataFields.patentCount)) {
            info.setPatentCount(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.patentCount))));
        }
        if (enterpriseInfos.containsKey(DataFields.averageOrderResponseSpeed)) {
            info.setAverageOrderResponseSpeed(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.averageOrderResponseSpeed))));
        }
        if (enterpriseInfos.containsKey(DataFields.eventTime)) {
            info.setEventTime(Long.parseLong(String.valueOf(enterpriseInfos.get(DataFields.eventTime))));
        }
        return info;
    }

    public SaleCapabilityInfo extractSaleCapabilityInfos(Map<String, Object> enterpriseInfos) {
//        List<SaleCapabilityInfo> saleCapabilityInfos = new ArrayList<>();
//        try {
//            SaleCapabilityInfo info = new SaleCapabilityInfo();
//            if (enterpriseInfos.containsKey(DataFields.chainType)) {
//                info.setChainType(String.valueOf(enterpriseInfos.get(DataFields.chainType)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.enterpriseName)) {
//                info.setEnterpriseName(String.valueOf(enterpriseInfos.get(DataFields.enterpriseName)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.scenario)) {
//                info.setScenario(String.valueOf(enterpriseInfos.get(DataFields.scenario)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.product)) {
//                info.setProduct(String.valueOf(enterpriseInfos.get(DataFields.product)));
//            }
//            if (enterpriseInfos.containsKey(DataFields.customerCount)) {
//                info.setCustomerCount(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.customerCount))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.marketShare)) {
//                info.setMarketShare(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.marketShare))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.annualSales)) {
//                info.setAnnualSales(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.annualSales))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.onlineSalesRatio)) {
//                info.setOnlineSalesRatio(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.onlineSalesRatio))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.offlineSalesRatio)) {
//                info.setOfflineSalesRatio(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.offlineSalesRatio))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.averageCustomerSatisfaction)) {
//                info.setAverageCustomerSatisfaction(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.averageCustomerSatisfaction))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.customerComplaintRate)) {
//                info.setCustomerComplaintRate(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.customerComplaintRate))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.customerRepurchaseRate)) {
//                info.setCustomerRepurchaseRate(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.customerRepurchaseRate))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.averageOrderProcessingTime)) {
//                info.setAverageOrderProcessingTime(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.averageOrderProcessingTime))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.averageDeliveryTime)) {
//                info.setAverageDeliveryTime(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.averageDeliveryTime))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.annualMarketingBudget)) {
//                info.setAnnualMarketingBudget(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.annualMarketingBudget))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.brandAwareness)) {
//                info.setBrandAwareness(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.brandAwareness))));
//            }
//            if (enterpriseInfos.containsKey(DataFields.eventTime)) {
//                info.setEventTime(Long.parseLong(String.valueOf(enterpriseInfos.get(DataFields.eventTime))));
//            }
//
//            saleCapabilityInfos.add(info);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//
        //enterpriseBasicInfoService.addSaleCapabilityInfos(saleCapabilityInfos);
        //return saleCapabilityInfos;

        SaleCapabilityInfo info = new SaleCapabilityInfo();
        if (enterpriseInfos.containsKey(DataFields.chainType)) {
            info.setChainType(String.valueOf(enterpriseInfos.get(DataFields.chainType)));
        }
        if (enterpriseInfos.containsKey(DataFields.enterpriseName)) {
            info.setEnterpriseName(String.valueOf(enterpriseInfos.get(DataFields.enterpriseName)));
        }
        if (enterpriseInfos.containsKey(DataFields.scenario)) {
            info.setScenario(String.valueOf(enterpriseInfos.get(DataFields.scenario)));
        }
        if (enterpriseInfos.containsKey(DataFields.product)) {
            info.setProduct(String.valueOf(enterpriseInfos.get(DataFields.product)));
        }
        if (enterpriseInfos.containsKey(DataFields.customerCount)) {
            info.setCustomerCount(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.customerCount))));
        }
        if (enterpriseInfos.containsKey(DataFields.marketShare)) {
            info.setMarketShare(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.marketShare))));
        }
        if (enterpriseInfos.containsKey(DataFields.annualSales)) {
            info.setAnnualSales(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.annualSales))));
        }
        if (enterpriseInfos.containsKey(DataFields.onlineSalesRatio)) {
            info.setOnlineSalesRatio(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.onlineSalesRatio))));
        }
        if (enterpriseInfos.containsKey(DataFields.offlineSalesRatio)) {
            info.setOfflineSalesRatio(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.offlineSalesRatio))));
        }
        if (enterpriseInfos.containsKey(DataFields.averageCustomerSatisfaction)) {
            info.setAverageCustomerSatisfaction(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.averageCustomerSatisfaction))));
        }
        if (enterpriseInfos.containsKey(DataFields.customerComplaintRate)) {
            info.setCustomerComplaintRate(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.customerComplaintRate))));
        }
        if (enterpriseInfos.containsKey(DataFields.customerRepurchaseRate)) {
            info.setCustomerRepurchaseRate(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.customerRepurchaseRate))));
        }
        if (enterpriseInfos.containsKey(DataFields.averageOrderProcessingTime)) {
            info.setAverageOrderProcessingTime(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.averageOrderProcessingTime))));
        }
        if (enterpriseInfos.containsKey(DataFields.averageDeliveryTime)) {
            info.setAverageDeliveryTime(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.averageDeliveryTime))));
        }
        if (enterpriseInfos.containsKey(DataFields.annualMarketingBudget)) {
            info.setAnnualMarketingBudget(new BigDecimal(String.valueOf(enterpriseInfos.get(DataFields.annualMarketingBudget))));
        }
        if (enterpriseInfos.containsKey(DataFields.brandAwareness)) {
            info.setBrandAwareness(Integer.parseInt(String.valueOf(enterpriseInfos.get(DataFields.brandAwareness))));
        }
        if (enterpriseInfos.containsKey(DataFields.eventTime)) {
            info.setEventTime(Long.parseLong(String.valueOf(enterpriseInfos.get(DataFields.eventTime))));
        }
        return info;
    }
}
